<template>
  <div id="app">
    <router-view v-if="isRouterAlive"/>
  </div>
</template>

<style lang="scss">
  body{
    margin: 0;
    padding: 0;
  };
  template{
    zoom: 0.2;
  }
</style>
<script>
export default {
  name: 'app',
  provide () {
    return {
      reload: this.reload
    }
  },
  mounted () {
    window.addEventListener('unload', this.saveState)
    // console.log('高度是：', window.innerHeight)
    // window.addEventListener('resize', () => {
    //   window.innerHeight = window.innerHeight * 0.8
    //   window.innerWidth = window.innerWidth * 0.8
    //   console.log('修改后的高度是：', window.innerHeight)
    //   console.log('修改后的宽度是：', window.innerWidth)
    // })
  },
  data () {
    return {
      isRouterAlive: true,
      maxAgeTime: new Date().getTime() + 1000 * 3600,
      height: window.innerHeight
    }
  },
  methods: {
    reload () {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    },
    saveState () {
      console.log('页面刷新')
      // window.localStorage.setItem('user', JSON.stringify(this.$store.getters.getUser))
      window.localStorage.setItem('factory', JSON.stringify({ value: this.$store.getters.getFactory, maxAgeTime: this.maxAgeTime }))
      window.localStorage.setItem('reportUrl', JSON.stringify({ value: this.$store.getters.getReportUrl, maxAgeTime: this.maxAgeTime }))
    }
  }
}
</script>

<style>
  /*#app{*/
  /*  height: 100%;*/
  /*  width: 100%;*/
  /*  display: flex;*/
  /*  flex-direction: column;*/
  /*  justify-content: center;*/
  /*  align-items: center;*/
  /*  zoom: 0.75;*/
  /*}*/
</style>
